#include <cstdio>
#include <queue>
using namespace std;
//To deep your understanding between DFS and BFS from solving this question.
typedef struct nod{
    int x, y, z;
}node;
int M, N, L, T;
int pixels[1287][129][61];
bool vis[1287][129][61] = {false};
//DFS of the graph is analogous to the level traversal of the binary tree
queue<node> que;
//增量数组，用于遍历一个结点的相邻结点
int X[] = {0, 0, 0, 0, 1, -1};
int Y[] = {0, 0, 1, -1, 0, 0};
int Z[] = {1, -1, 0, 0, 0, 0};
bool judge(int x, int y, int z)
{//这里判断是否越界，以及结点值是否为1
    if(x >= 0 && x < M && y >= 0 && y < N && z >= 0 && z < L)
    {
        if(1 == pixels[x][y][z] && false == vis[x][y][z])return true;//还要求未被访问过!!!
        else return false;
    }else return false;
}
int BFS(int x, int y, int z)
{
    int count = 0;
    node temp, top;
    int newx, newy, newz;
    temp.x = x; temp.y = y; temp.z = z;
    que.push(temp);
    vis[x][y][z] = true;
    while(!que.empty())
    {
        top = que.front();
        que.pop();
        ++count;
        for(int i = 0; i < 6; ++i)
        {
            newx = top.x + X[i];
            newy = top.y + Y[i];
            newz = top.z + Z[i];
            if(judge(newx, newy, newz))
            {
                vis[newx][newy][newz] = true;
                temp.x = newx; temp.y = newy; temp.z = newz;
                que.push(temp);
            }
        }
    }
    if(count >= T)return count;
    else return 0;
}
main()
{
    scanf("%d%d%d%d", &M, &N, &L, &T);
    int x, y, z;
    int total = 0;
    for(z = 0; z < L; ++z)
        for(x = 0; x < M; ++x)
            for(y = 0; y < N; ++y)
                scanf("%d", &pixels[x][y][z]);
    for(z = 0; z < L; ++z)
        for(x = 0; x < M; ++x)
            for(y = 0; y < N; ++y)
                if(1 == pixels[x][y][z] && false == vis[x][y][z])
                    total += BFS(x, y, z);
    printf("%d\n", total);
    return 0;
}